home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d21 / dvglue10.arc / TVINT15W.C < prev    next >
C/C++ Source or Header  |  1988-08-13  |  4KB  |  100 lines

  1. /*=======================================================*/
  2. /*  TVINT15W.C                                           */
  3. /*     low-level functions to send streams to windows    */
  4. /*     requires MASM or A86 to recompile                 */
  5. /*                                                       */
  6. /*  (c) Copyright 1988 Ralf Brown  All Rights Reserved   */
  7. /*  May be freely copied for noncommercial use, so long  */
  8. /*  as this copyright notice remains intact, and any     */
  9. /*  changes are marked in the comment blocks preceding   */
  10. /*  functions.                                           */
  11. /*=======================================================*/
  12.  
  13. #pragma inline
  14.  
  15. #include "tvapi.h"
  16. #include "tvstream.h"
  17.  
  18. /*======================================================*/
  19. /* TVwin_stream--send a stream to specified window      */
  20. /*                 do not use with opcode 0xE6          */
  21. /*   Ralf Brown 4/3/88                                  */
  22. /*======================================================*/
  23.  
  24. void pascal TVwin_stream(OBJECT window,BYTE *stream)
  25. {
  26. #if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
  27.    asm push ds          ; /* pass pointer to stream to TV */
  28.    asm mov  bx,stream
  29.    asm push bx
  30.    asm xor  ax,ax       ; /* get length of stream */
  31.    asm push ax
  32.    asm mov  ax,[bx+2]
  33. #else
  34.    asm les  bx,stream   ; /* get pointer to stream */
  35.    asm push es          ; /* and pass it to TV */
  36.    asm push bx
  37.    asm xor  ax,ax       ; /* get length of stream */
  38.    asm push ax
  39.    asm mov  ax,es:[bx+2]
  40. #endif
  41.    asm add  ax,4        ; /* adjust for stream header */
  42.    asm push ax          ; /* and push total length */
  43.    asm les  bx,window   ; /* get object handle */
  44.    asm mov  ax,es
  45.    asm or   ax,bx       ; /* was handle NULL? */
  46.    asm je   null_handle
  47.    asm push es          ; /* and push it if non-NULL */
  48.    asm push bx
  49.    asm mov  bl,0        ; /* object is TOS */
  50.    asm jmp  short nonull
  51. null_handle:
  52.    asm mov  bl,1        ; /* object is ME */
  53. nonull:
  54.    asm mov  ah,12h      ; /* SEND message */
  55.    asm mov  bh,05h      ; /* message is WRITE */
  56.    asm int  15h         ; /* do it */
  57. }
  58.  
  59. /*======================================================*/
  60. /* TVwin_new--create a new window from specified window */
  61. /*   Ralf Brown 4/3/88                                  */
  62. /*======================================================*/
  63.  
  64. OBJECT pascal TVwin_new(OBJECT window,int rows,int cols)
  65. {
  66.    static BYTE stream[] = { S_WINDOW(3), 0xE6, 0, 0 } ;
  67.    unsigned seg, ofs ;
  68.  
  69.    stream[5] = rows ;
  70.    stream[6] = cols ;
  71.  
  72.    asm lea  bx,stream   ; /* get pointer to stream */
  73.    asm push ds          ; /* and pass it to TV */
  74.    asm push bx
  75.    asm xor  ax,ax       ; /* get length of stream */
  76.    asm push ax
  77.    asm mov  ax,7
  78.    asm push ax          ; /* and push it, too */
  79.    asm les  bx,window   ; /* get object handle */
  80.    asm mov  ax,es
  81.    asm or   ax,bx       ; /* was handle NULL? */
  82.    asm je   null_handle
  83.    asm push es          ; /* and push it if non-NULL */
  84.    asm push bx
  85.    asm mov  bl,0        ; /* object is TOS */
  86.    asm jmp  short nonull
  87. null_handle:
  88.    asm mov  bl,1        ; /* object is ME */
  89. nonull:
  90.    asm mov  ah,12h      ; /* SEND message */
  91.    asm mov  bh,05h      ; /* message is WRITE */
  92.    asm int  15h         ; /* do it */
  93.    asm pop  ofs         ; /* get returned object handle */
  94.    asm pop  seg
  95.  
  96.    return MK_FP(seg,ofs) ;
  97. }
  98.  
  99. /* End of TVINT15W.C */
  100.